package rule

import "strconv"

func init() {
	Register(&numberRule{})
}

type numberRule struct {
}

func (n *numberRule) Name() string {
	return "number"
}

func (n *numberRule) Check(in *RuleInput) (err error) {
	if in.Value != nil {
		switch in.Value.(type) {
		case uint, uint8, uint16, uint32, uint64:
			return
		case string:
			if _, err1 := strconv.ParseUint(in.Value.(string), 10, 64); err1 == nil {
				return
			}
		}
	}
	return in.Error()
}
